<?

class CCollapsedList
{
	var $name, $item_count;
	
	function CCollapsedList($name)
	{
		$this->name = $name;
		$this->item_count = 0;
	}
	
	function PrintJS()
	{
		global $r;
		$n = $this->name;
		echo
'<script type="text/javascript" language="JavaScript">
var img_pls = new Image();  img_pls.src="'.$r.'images/plus.gif";
var img_mns = new Image();  img_mns.src="'.$r.'images/minus.gif";

function '.$n.'setSection(secNum, doOpen) {
	if (doOpen) { 
		document.getElementById("'.$n.'div"+secNum).style.display="";
		document.getElementById("'.$n.'img"+secNum).src=img_mns.src;
	} else {
		document.getElementById("'.$n.'div"+secNum).style.display="none";
		document.getElementById("'.$n.'img"+secNum).src=img_pls.src;
	}	
}
function '.$n.'isSection(secNum) {
	if (document.getElementById("'.$n.'div"+secNum).style.display=="none")
		return false;	
	return true;
}
function '.$n.'doSection(secNum) {
	'.$n.'setSection(secNum, !'.$n.'isSection(secNum));
}
function '.$n.'noSection(secNum) {
	'.$n.'setSection(secNum, false);
}
</script>

';
	}

	function PrintItem($title, $text)
	{
		$this->PrintItemPartAB($title);
		echo $text;
		$this->PrintItemPartC();
	}
	
	function PrintItemPartAB($title)
	{
		$this->PrintItemPartA();
		echo $title;
		$this->PrintItemPartB();
	}

	function PrintItemPartA()
	{
		global $r;
		$n = $this->name;
		$id = ++$this->item_count;

		$a = '<a href="#nowhere" onclick='.$n.'doSection('.$id.')>';
	    echo '<p class=text style="margin-top:4">'."\n".
		     $a.'<img id='.$n.'img'.$id.' src="'.$r.'images/plus.gif" width=9 height=9 border=0></a>&nbsp;'."\n".
		     $a;
	}
	function PrintItemPartB()
	{
		$n = $this->name;
		$id = $this->item_count;

	    echo '</a>'."\n";
	    echo '<div id='.$n.'div'.$id.' style="display:none; margin:10; margin-left:25" class="text">';
	}
	function PrintItemPartC()
	{
	    echo '</div>'."\n\n";
	}
	
	function PrintJS2($do_expand)
	{
		global $expand;
		$n = $this->name;
		echo
'<script type="text/javascript" language="JavaScript">
function '.$n.'expand_all() {
	var i, last='.$this->item_count.', doOpen=false;
	for(i=1; i<=last; i++){if (!'.$n.'isSection(i)) doOpen=true}
	for(i=1; i<=last; i++){'.$n.'setSection(i,doOpen)}
}
';
		if ($do_expand || isset($expand) && $expand) echo $n.'expand_all()'."\n";
		echo
'</script>

';
	}
}

?>


